package com.seuic.hnjiningposapp.hnapps.util;

import android.annotation.SuppressLint;
import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.DeviceUtils;
import com.blankj.utilcode.util.EncryptUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.SPStaticUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.seuic.posdsdk.pos_func.PosFuncs;
import com.socks.library.KLog;

import java.io.IOException;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.TimeUnit;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

import static com.seuic.hnjiningposapp.hnapps.util.Api.RETURN_CODE_SUCCEED;

/**
 * @author rainking
 */
public class HttpUtilsV2 {
    private static final String TAG = HttpUtilsV2.class.getName();

    private static final int KEY_RANDOM = 13;

    /**
     * log 输出
     *
     * @param msg 内容
     */
    public static void log(String msg) {
        System.out.println(msg);
    }


    private HttpUtilsV2() {

    }

    private static OkHttpClient getOkHttpClient() {
        //配置了网络请求的超时时间
        return new OkHttpClient().newBuilder()
                .connectTimeout(30, TimeUnit.SECONDS)
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                //支持HTTPS请求，跳过证书验证
                .sslSocketFactory(getSSLSocketFactory())
                .hostnameVerifier((hostname, session) -> true)
                .build();
    }

    /**
     * 获取这个SSLSocketFactory
     */
    private static SSLSocketFactory getSSLSocketFactory() {
        try {
            SSLContext sslContext = SSLContext.getInstance("SSL");
            sslContext.init(null, getTrustManager(), new SecureRandom());
            return sslContext.getSocketFactory();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    //获取TrustManager
    private static TrustManager[] getTrustManager() {
        return new TrustManager[]{
                new X509TrustManager() {
                    @SuppressLint("TrustAllX509TrustManager")
                    @Override
                    public void checkClientTrusted(X509Certificate[] chain, String authType) {
                    }

                    @SuppressLint("TrustAllX509TrustManager")
                    @Override
                    public void checkServerTrusted(X509Certificate[] chain, String authType) {
                    }

                    @Override
                    public X509Certificate[] getAcceptedIssuers() {
                        return new X509Certificate[]{};
                    }
                }
        };
    }


    /**
     * 回调接口
     */
    public interface NetCallBack {

        void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody);

        void onError(String code, String msg);
    }

    /**
     * 执行普通的post请求，参数集合全部转为json
     *
     * @param map         传入的参数集合
     * @param netCallBack 回调接口
     */
    private static void postByOkGo(String json, NetCallBack netCallBack) {


        if (!NetWorkUtils.isNetworkConnected()) {
            netCallBack.onError("0", "暂无网络连接,请检查您的网络");
        } else {
            log("入参:" + json);
            Request request = new Request.Builder()
                    .url(Api.BASE_URL)
                    .post(RequestBody.create(MediaType.parse("application/json;charset=GB18030"), json))
                    .build();
            Response response;
            try {
                response = getOkHttpClient().newCall(request).execute();
                if (!response.isSuccessful()) {
                    if (netCallBack != null) {
                        netCallBack.onError("-1", "Unexpected code " + response);
                    }
                } else {
                    String result = gB18030ByteArrayToUtf8String(Objects.requireNonNull(response.body()).bytes());
                    JSONObject body = JSON.parseObject(result);
                    log("出参(全部):" + JSON.toJSONString(body));
                    JSONObject sysHead = body.getJSONObject("SYS_HEAD");
                    String returnCode = sysHead.getString("ReturnCode");
                    String returnMessage = sysHead.getString("ReturnMessage");
                    String ServerSeqNo = sysHead.getString("ServerSeqNo");
                    String ConsumerSeqNo = sysHead.getString("ConsumerSeqNo");

                    if (returnCode.equals(RETURN_CODE_SUCCEED)) {
                        JSONObject rspBody = body.getJSONObject("RSP_BODY");
                        log("出参 rspBody:" + JSON.toJSONString(rspBody));
                        if (netCallBack != null) {
                            netCallBack.onSuccess(ServerSeqNo, ConsumerSeqNo, rspBody);
                        }
                    } else {
                        if (netCallBack != null) {
                            netCallBack.onError(returnCode, returnMessage);
                        }
                    }
                }
            } catch (SocketTimeoutException e) {
                KLog.e(e);
                netCallBack.onError("0", "链接超时，请重试");
            } catch (IOException e) {
                KLog.e(e);
                e.printStackTrace();
            }
        }
    }


    private static String gB18030ByteArrayToUtf8String(byte[] bytes) {
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        CharBuffer gb18030 = Charset.forName("GB18030").decode(byteBuffer);
        ByteBuffer utf8 = StandardCharsets.UTF_8.encode(gb18030);
        return new String(utf8.array());
    }


    /**
     * @param transServiceCode 交易码
     * @param menuCode         菜单代码
     * @param reqBody          参数（Map）
     * @return String
     */
    private static String getParameterMap(String transServiceCode, String menuCode, Map<String, Object> reqBody) {
        Date date = new Date(System.currentTimeMillis());

        String requestDate = TimeUtils.date2String(date, "yyyyMMdd");
        String requestTime = TimeUtils.date2String(date, "hhmmss");

        StringBuilder random = new StringBuilder();
        for (int i = 0; i < KEY_RANDOM; i++) {
            Random ra = new Random();
            random.append((ra.nextInt(10) + 1));
        }
        String consumerSeqNo = "GSUTE" + requestDate + requestTime + random.toString();


        Map<String, Object> jsonHead = new HashMap<>(3);
        Map<String, Object> sysHead = new HashMap<>(30);
        //渠道号码	服务原始请求系统的系统编号C002
        sysHead.put("ConsumerId", "030107");
        //外部服务码	AFA服务码 -交易码
        sysHead.put("TransServiceCode", transServiceCode);
        //服务场景	本地服务场景
        sysHead.put("TransServiceScenc", "");
        //服务请求日期	服务请求系统的日期，格式为YYYYMMDD
        sysHead.put("RequestDate", requestDate);
        //服务请求时间	服务请求系统的时间，格式为HHMMSS
        sysHead.put("RequestTime", requestTime);
        //发起方系统流水号	服务原始请求系统的交易流水号,用来唯一标识一笔业务
        sysHead.put("ConsumerSeqNo", consumerSeqNo);
        //发起方IP	请求方IP地址
        sysHead.put("ConsumerIP", NetworkUtils.getBroadcastIpAddress());
//        sysHead.put("ConsumerIP", "22.1.7.15");
        //目标服务器IP	服务方IP地址
        sysHead.put("ServerIP", Api.BASE_URL);
        //交易模式	1－同步处理；2－异步处理
        sysHead.put("TranMode", "1");
        //Mac值	MAC校验值(如果请求报文需要校验MAC，则需要填写这个字段)
        sysHead.put("MacValue", DeviceUtils.getMacAddress().replace(":", "").toUpperCase());
//        sysHead.put("MacValue", "B436A923C7C2");


        //交易机构代码	交易机构代码
        sysHead.put("TdgBrah", SPStaticUtils.getString("TdgBrah"));
//        sysHead.put("TdgBrah", "815012501");
        //交易机构名称
        sysHead.put("TdgBrahName", SPStaticUtils.getString("TdgBrahName"));
//        sysHead.put("TdgBrahName", "济宁银行金乡支行");
        //交易柜员号	交易柜员号
        sysHead.put("TranTellerNo", SPStaticUtils.getString("TranTellerNo"));
//        sysHead.put("TranTellerNo", "81500841");
        //交易柜员名称	柜员名称
        sysHead.put("TranTellerName", SPStaticUtils.getString("TranTellerName"));
//        sysHead.put("TranTellerName", "金乡测试003");
        //设备类型
        sysHead.put("DeviceType", SPStaticUtils.getString("DeviceType"));
//        sysHead.put("DeviceType", "");
        //设备编码	V端分配
        sysHead.put("DeviceNum", SPStaticUtils.getString("DeviceNum"));
//        sysHead.put("DeviceNum", "30100101");
        //设备代码	根据机具MAC等信息计算得出
        sysHead.put("DvcNum", PosFuncs.getInstace().getTermSerial());
//        sysHead.put("DvcNum", "0000200401BX8B007690");
        //菜单代码	C端菜单ID
        sysHead.put("MenuCode", menuCode);

        jsonHead.put("SYS_HEAD", sysHead);
        Map<String, Object> appHead = new HashMap<>(30);
        //文件索引号
        appHead.put("MMDATE", "");
        //视频日期
        appHead.put("MMID", "");
        //视频ID
        appHead.put("FILEINDXNO", "");
        //呼入渠道号
        appHead.put("CHANNELCODE", "");
        //附加数据域
        appHead.put("OTHERDATA", "");
        //未知（SUTE）
        appHead.put("IttrStmInd", "SUTE");
        //语言版本
        appHead.put("I18nInd", "CH");
        //坐席号
        appHead.put("AgentId", "");
        //坐席号级别
        appHead.put("AgentLevel", "");
        //授权坐席号
        appHead.put("Auth_AgentId", "");
        //IC卡号	IC卡必送
        appHead.put("CardNo", SPStaticUtils.getString("CardNo-bindNum"));
//        appHead.put("CardNo", "6231160001010483492");
        //55域	IC卡必送
        appHead.put("Card55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
//        appHead.put("Card55", "9F269F109F369A9F02829F030500000000009F339F35849F41");
        //电子现金余额	IC卡必送
        appHead.put("CardEcBalance", "000000000000");
        //卡序号	IC卡必送
        appHead.put("CardSeqNo", SPStaticUtils.getString("CardSeqNo"));
//        appHead.put("CardSeqNo", "01");
        //55域长度	Card55字段值得长度除以2转16进制

        appHead.put("Card55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));
        //授权坐席号级别
        appHead.put("Auth_AgentLevel", "");
        jsonHead.put("APP_HEAD", appHead);
        jsonHead.put("REQ_BODY", reqBody);

        return JSON.toJSONString(jsonHead);
    }


    /**
     * 设备激活
     *
     * @param TdgBrah      机构号、网点号
     * @param OperTellerNo 操作柜员号
     * @param TellerPwd    柜员密码
     * @param DvcNum       根据机具MAC等信息计算得出（设备编号）
     * @param VrsnNum      软件版本号
     */
    public static void getDeviceActivation(String TdgBrah, String OperTellerNo, String TellerPwd, String DvcNum, NetCallBack netCallBack) {
        log("设备激活 开始");
        Map<String, Object> reqBody = new HashMap<>(6);
        reqBody.put("TdgBrah", TdgBrah);
        reqBody.put("OperTellerNo", OperTellerNo);
        reqBody.put("TellerPwd", EncryptUtils.encryptMD5ToString(TellerPwd).toUpperCase());
        reqBody.put("DvcNum", DvcNum);
        reqBody.put("TranTellerNo", "");
        reqBody.put("VrsnNum", "");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.device.d001.01", "", reqBody)
                        , netCallBack);
                log("设备激活 结束");
            }
        }).start();

    }


    /**
     * 设备查询
     */
    public static void getEquipmentInquiry(NetCallBack netCallBack) {
        log("设备查询 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameter("pcva.query.q008.01")
                        , netCallBack);
                log("设备查询 结束");
            }
        }).start();


    }

    /**
     * 获取工作秘钥
     */
    public static void getWorkKey(NetCallBack netCallBack) {
        log("获取工作秘钥 开始");
        postByOkGo(getParameter("pcva.device.d006.01")
                , netCallBack);
        log("获取工作秘钥 结束");

    }


    /**
     * 签到
     *
     * @param TellerNo  柜员号
     * @param TellerPwd 柜员密码
     */
    public static void getSignIn(String TellerNo, String TellerPwd, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(6);
        reqBody.put("TellerNo", TellerNo);
        reqBody.put("TellerPwd", EncryptUtils.encryptMD5ToString(TellerPwd).toUpperCase());
        reqBody.put("LoginType", "1");
//        reqBody.put("DvcNum", SPStaticUtils.getString("DeviceNum"));
        reqBody.put("DvcNum", "30100101");
        reqBody.put("FingerData", "");
        reqBody.put("type", "1");

        log("签到 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.device.d003.01", "", reqBody)
                        , netCallBack);
                log("签到 结束");
            }
        }).start();

    }


    /**
     * 验证是否为本行卡
     *
     * @param AcctNo 账号
     */
    public static void getCheckingThisBank(String AcctNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("SubAcctNo", "");
        reqBody.put("PinBlock", "");

        log("验证是否为本行卡 开始");
        new Thread(() -> {
            postByOkGo(getParameterMap("pcva.trade.b071.01", "", reqBody)
                    , netCallBack);
            log("验证是否为本行卡 结束");
        }).start();

    }

    /**
     * 验证是否为本行卡
     *
     * @param AcctNo 账号
     */
    public static void getCheckingThisBanks(String AcctNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("SubAcctNo", "");
        reqBody.put("PinBlock", "");

        log("验证是否为本行卡 开始");
        new Thread(() -> {
            postByOkGo(getParameterMap("pcva.trade.b071.01", "300007", reqBody)
                    , netCallBack);
            log("验证是否为本行卡 结束");
        }).start();

    }

    /**
     * 银行卡信息查询
     *
     * @param AcctNo 账号
     */
    public static void getQueryBankCardInfo(String AcctNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(3);
        reqBody.put("AcctNo", AcctNo);
        log("银行卡信息查询 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b031.01", "", reqBody)
                        , new NetCallBack() {


                            @Override
                            public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                                if (netCallBack != null) {
                                    rspBody.put("AcctNo", AcctNo);
                                    netCallBack.onSuccess(ServerSeqNo, ConsumerSeqNo, rspBody);
                                }
                            }

                            @Override
                            public void onError(String code, String msg) {
                                if (netCallBack != null) {
                                    netCallBack.onError(code, msg);
                                }
                            }
                        });
                log("银行卡信息查询 结束");
            }
        }).start();

    }

    /**
     * 上传冠字号  流水号
     *
     * @param ChannelSerno 流水号
     * @param SerialNumber 冠字号
     */
    public static void upGzAndWNum(String ChannelSerno, String SerialNumber, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>();
        reqBody.put("ChannelSerno", ChannelSerno);
        reqBody.put("SerialNumber", SerialNumber);
        log("上传冠字号  流水号开始");
        postByOkGo(getParameterMap("pcva.trade.s001.01", "", reqBody)
                , netCallBack);
        log("上传冠字号  流水号结束");
    }

    /**
     * 银行卡信息查询
     *
     * @param AcctNo 账号
     */
    public static void getQueryBankCardInfos(String AcctNo, String menucode, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(3);
        reqBody.put("AcctNo", AcctNo);
        log("银行卡信息查询 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b031.01", menucode, reqBody)
                        , new NetCallBack() {
                            @Override
                            public void onSuccess(String ServerSeqNo, String ConsumerSeqNo, JSONObject rspBody) {
                                if (netCallBack != null) {
                                    rspBody.put("AcctNo", AcctNo);
                                    netCallBack.onSuccess(ServerSeqNo, ConsumerSeqNo, rspBody);
                                }
                            }

                            @Override
                            public void onError(String code, String msg) {
                                if (netCallBack != null) {
                                    netCallBack.onError(code, msg);
                                }
                            }
                        });
                log("银行卡信息查询 结束");
            }
        }).start();

    }


    /**
     * 账户密码验证
     *
     * @param AcctNo   账号
     * @param PinBlock 账户密码
     */
    public static void getAccountPwdVerification(String AcctNo, String PinBlock, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(3);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("PinBlock", PinBlock);

        log("账户密码验证 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b029.01", "", reqBody)
                        , netCallBack);
            }
        }).start();
        log("账户密码验证 结束");
    }

    /**
     * 黑名单校验
     *
     * @param AcctNo     账号
     * @param PayActName 账户名称
     */
    public static void getCheckingBankCardBlacklist(String PayActNo, String PayActName, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(2);
        reqBody.put("PayActNo", PayActNo);
        reqBody.put("PayActName", PayActName);
        new Thread(new Runnable() {
            @Override
            public void run() {
                log("黑名单校验 开始");
                postByOkGo(getParameterMap("pcva.trade.b072.01", "", reqBody)
                        , netCallBack);
                log("黑名单校验 结束");
            }
        }).start();

    }


    /**
     * 账户限额及交易次数查询
     *
     * @param AcctNo 账号
     */
    public static void getQueryAccountNorm(String AcctNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("AcctNo", AcctNo);
        new Thread(new Runnable() {
            @Override
            public void run() {
                log("账户限额及交易次数查询 开始");
                postByOkGo(getParameterMap("pcva.trade.p002.01", "", reqBody)
                        , netCallBack);
                log("账户限额及交易次数查询 结束");
            }
        }).start();

    }


    /**
     * 行名行号查询
     *
     * @param AcctNo 银行名称
     */
    public static void getQueryAliasBankCardInfo(String BankName, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("BankName", BankName);
        log("行名行号查询 开始");
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b075.01", "", reqBody)
                , netCallBack)).start();
        log("行名行号查询 结束");
    }


    /**
     * 手续费查询
     *
     * @param PayAcctNo   付款账号
     * @param PayBankNo   付款账号开户行
     * @param PayeeBankNo 收款行行号
     * @param PayeeAcctNo 收款账号
     * @param Amount      金额
     */
    public static void getQueryServiceCharge(String PayAcctNo, String PayBankNo, String PayeeBankNo, String PayeeAcctNo, String Amount
            , NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(5);
        reqBody.put("PayAcctNo", PayAcctNo);
        reqBody.put("PayBankNo", PayBankNo);
        reqBody.put("PayeeBankNo", PayeeBankNo);
        reqBody.put("PayeeAcctNo", PayeeAcctNo);
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            if (netCallBack != null) {
                netCallBack.onError("-1", numberFormatException.getMessage());
            }
            return;
        }
        log("手续费查询 开始");
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b076.01", "", reqBody)
                , netCallBack)).start();
        log("手续费查询 结束");

    }

    /**
     * 转账
     *
     * @param PayActNo     付款账号
     * @param PayActName   付款账户名称
     * @param PayeeActNo   收款账号
     * @param PayeeActName 收款账户名称
     * @param PayeeBankNo  收款行行号
     * @param PinBlock     账户密码
     * @param Amount       金额
     * @param TransferType 转账方式 1：本行 2：跨行
     * @param TradeFee     手续费
     */

    public static void getTransfer(String PayActNo, String PayActName,
                                   String PayeeActNo, String PayeeActName,
                                   String PayeeBankNo, String PinBlock,
                                   String Amount, String TransferType, String TradeFee, String menuCode, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(10);
        reqBody.put("PayActNo", PayActNo);
        reqBody.put("PayActName", PayActName);
        reqBody.put("PayeeActNo", PayeeActNo);
        reqBody.put("PayeeActName", PayeeActName);
        reqBody.put("PayeeBankNo", PayeeBankNo);
        reqBody.put("PinBlock", PinBlock);
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            if (netCallBack != null) {
                netCallBack.onError("-1", numberFormatException.getMessage());
            }
            return;
        }
        reqBody.put("TransferPriority", "1");
        reqBody.put("TransferType", TransferType);
        reqBody.put("TradeFee", TradeFee);

        log("转账 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b052.01", menuCode, reqBody), netCallBack);
                log("转账 结束");
            }
        }).start();

    }


    /**
     * 本代他余额查询 校验密码
     *
     * @param AcctNo         主账号
     * @param TwoTrack       第二磁道数据
     * @param ThreeTrack     第三磁道数据
     * @param PinBlock       自定义域
     * @param PersonFlg      个人标识码数据
     * @param ProxyBranchFlg 代理机构标识码
     * @param ServiceCode    服务点输入方式码
     * @param SignAgreeNum   签约协议号
     * @param CarNum         发起方卡号
     */
    public static void getCurrentBalanceCheck(String AcctNo, String TwoTrack,
                                              String ThreeTrack, String PinBlock,
                                              String PersonFlg, String ProxyBranchFlg,
                                              String ServiceCode, String SignAgreeNum,
                                              String CarNum, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(9);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("TwoTrack", TwoTrack);
        reqBody.put("ThreeTrack", ThreeTrack);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("PersonFlg", PersonFlg);
        reqBody.put("ProxyBranchFlg", ProxyBranchFlg);
        reqBody.put("ServiceCode", ServiceCode);
        reqBody.put("SignAgreeNum", SignAgreeNum);
        reqBody.put("CarNum", CarNum);
        reqBody.put("AppHeadCardNo", CarNum);
        reqBody.put("AppHeadCard55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
        reqBody.put("AppHeadCardEcBalance", SPStaticUtils.getString("000000000000"));
        reqBody.put("AppHeadCardSeqNo", SPStaticUtils.getString("CardSeqNo"));
        reqBody.put("AppHeadCard55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));
        log("本代他余额查询 开始");
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b096.01", "", reqBody)
                , netCallBack)).start();

        log("本代他余额查询 结束");
    }

    /**
     * 他行卡转入
     *
     * @param PayeeName        收款方名称
     * @param PayerName        付款方名称
     * @param PosEntryModeCode 服务点输入方式码
     * @param PayeeAcctNo      转入卡号
     * @param PinBlock         密码密文
     * @param Amount           交易金额
     * @param ThreeTrack       第三磁道数据
     * @param SecondTrack      第二磁道数据
     * @param AcctNo           转出卡号
     */
    public static void getTransferOfOtherCards(String PayeeName, String PayerName,
                                               String PosEntryModeCode, String PayeeAcctNo,
                                               String PinBlock,
                                               String Amount, String ThreeTrack,
                                               String SecondTrack, String AcctNo
            , NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(11);
        reqBody.put("PayActName", PayerName);
        reqBody.put("PayeeActName", PayeeName);
        reqBody.put("POS_ENTRY_MODE_CODE", PosEntryModeCode);
        reqBody.put("PayActNo", AcctNo);
        reqBody.put("PINData", PinBlock);
        reqBody.put("PayeeActNo", PayeeAcctNo);
        reqBody.put("RESERVED", "00000500010000000000002");
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            if (netCallBack != null) {
                netCallBack.onError("-1", numberFormatException.getMessage());
            }
            return;
        }
        reqBody.put("ThreeTrack", ThreeTrack);
        reqBody.put("SecondTrack", SecondTrack);


        reqBody.put("AppHeadCardNo", AcctNo);
        reqBody.put("AppHeadCard55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
        reqBody.put("AppHeadCardEcBalance", SPStaticUtils.getString("000000000000"));
        reqBody.put("AppHeadCardSeqNo", SPStaticUtils.getString("CardSeqNo"));
        reqBody.put("AppHeadCard55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));
        log("他行卡转入 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b097.01", "100006", reqBody)
                        , netCallBack);
            }
        }).start();

        log("他行卡转入 结束");
    }

    /**
     * 合成电子印章
     *
     * @param type 电子印章类型
     * @param name 被核对人姓名
     */
    public static void getElectronicSeal(String type, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("type", type);
        new Thread(new Runnable() {
            @Override
            public void run() {
                log("合成电子印章 开始");
                postByOkGo(getParameterMap("pcva.trade.b091.01", "", reqBody)
                        , netCallBack);
                log("合成电子印章 结束");
            }
        }).start();

    }

    /**
     * 利率查询
     */
    public static void getInterestRateInquiry(NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        log("利率查询 开始");
        new Thread(() -> {
            postByOkGo(getParameterMap("pcva.trade.b070.01", "300006", reqBody), netCallBack);
            log("利率查询 结束");
        }).start();

    }

    /**
     * 子账户信息查询
     *
     * @param AcctNo   账号
     * @param PinBlock 密码
     * @param FUNC     功能代码
     */

    public static void getSubAccountInformationQuery(String AcctNo, String PinBlock, String FUNC, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(8);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("FUNC", FUNC);
        reqBody.put("PinBlock", PinBlock);
        log("子账户信息查询 开始");
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b074.01", "", reqBody), netCallBack)).start();
        log("子账户信息查询 结束");

    }

    public static void getSubAccountInformationQuerys(String AcctNo, String PinBlock, String FUNC, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(8);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("FUNC", FUNC);
        reqBody.put("PinBlock", PinBlock);
        log("子账户信息查询 开始");
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b074.01", "300004", reqBody), netCallBack)).start();
        log("子账户信息查询 结束");

    }


    /**
     * 联网核查
     *
     * @param id   被核对人身份证号码
     * @param name 被核对人姓名
     */
    public static void getNetworkVerification(String id, String name, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(2);
        reqBody.put("id", id);
        reqBody.put("name", name);
        log("联网核查 开始");
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b087.01", "400003", reqBody)
                , netCallBack)).start();
        log("联网核查 结束");

    }


    /**
     * 客户账户信息查询
     *
     * @param IDType 身份证件类型
     * @param IDNo   身份证件号码
     * @param IDName 证件姓名
     * @param AcctNo 账号
     */
    public static void getCustomerAccountInformationQuery(String IDType, String IDNo, String IDName,
                                                          String AcctNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(4);
        reqBody.put("IDType", IDType);
        reqBody.put("IDNo", IDNo);
        reqBody.put("IDName", IDName);
        reqBody.put("AcctNo", AcctNo);

        log("联网核查 开始");
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b030.01", "", reqBody)
                        , netCallBack);
            }
        }).start();

        log("联网核查 结束");

    }


    /**
     * 银行卡挂失
     *
     * @param AcctNo   账号
     * @param PinBlock 账户密码
     * @param IDType   身份证件类型
     * @param IDNo     身份证件号码
     * @return String
     */
    public static void getLostBankCard(String AcctNo,
                                       String PinBlock, String IDType, String IDNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(6);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("IDType", IDType);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("IDNo", IDNo);
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b060.01", "400002", reqBody), netCallBack)).start();
    }


    /**
     * 密码修改
     *
     * @param CardNo       卡号
     * @param OrigPinBlock 账户原密码
     * @param PinBlock     账户密码
     * @param CustName     客户名称
     * @param CustNo       客户号
     * @param IDType       身份证件类型
     * @param IDNo         身份证件号码
     * @param SecondTrack  二磁道
     * @return String
     */
    public static void getChangePassword(String CardNo, String OrigPinBlock,
                                         String PinBlock, String CustName, String CustNo,
                                         String IDType, String IDNo, String SecondTrack,
                                         NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(8);
        reqBody.put("CardNo", CardNo);
        reqBody.put("OrigPinBlock", OrigPinBlock);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("CustName", CustName);
        reqBody.put("CustNo", CustNo);
        reqBody.put("IDType", IDType);
        reqBody.put("IDNo", IDNo);
        reqBody.put("SecondTrack", SecondTrack);
        reqBody.put("AppHeadCardNo", CardNo);
        reqBody.put("AppHeadCard55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
        reqBody.put("AppHeadCardEcBalance", SPStaticUtils.getString("000000000000"));
        reqBody.put("AppHeadCardSeqNo", SPStaticUtils.getString("CardSeqNo"));
        reqBody.put("AppHeadCard55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b036.01", "400001", reqBody), netCallBack)).start();
    }


    /**
     * 账户活期明细查询
     *
     * @param AcctNo   账号
     * @param PinBlock 密码
     * @param FUNC     功能代码
     * @param STRDATE  开始日期
     * @param ENDDATE  截止日期
     * @return String
     */
    public static void getAccountCurrentDetailsInquiry(String AcctNo, String PinBlock,
                                                       String FUNC, String STRDATE, String ENDDATE
            , NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(5);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("FUNC", FUNC);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("STRDATE", STRDATE);
        reqBody.put("ENDDATE", ENDDATE);
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b073.01", "300003", reqBody),
                netCallBack)).start();

    }


    /**
     * 账户定期明细查询
     *
     * @param AcctNo      账号
     * @param PinBlock    密码
     * @param FUNC        功能代码
     * @param STRDATE     开始日期
     * @param ENDDATE     截止日期
     * @param PSBK_SQ_NO  本册笔号
     * @param SecondTrack 二磁道
     * @return String
     */
    public static void getAccountDetailsInquiry(String AcctNo, String PinBlock, String FUNC, String STRDATE,
                                                String ENDDATE, String PSBK_SQ_NO, String SecondTrack, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(7);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("FUNC", FUNC);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("STRDATE", STRDATE);
        reqBody.put("ENDDATE", ENDDATE);
        reqBody.put("PSBK_SQ_NO", PSBK_SQ_NO);
        reqBody.put("SecondTrack", SecondTrack);


        reqBody.put("AppHeadCardSeqNo", SPStaticUtils.getString("CardSeqNo"));
        reqBody.put("AppHeadCardEcBalance", SPStaticUtils.getString("000000000000"));
        reqBody.put("AppHeadCard55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
        reqBody.put("AppHeadCard55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));
        reqBody.put("AppHeadCardNo", SPStaticUtils.getString("CardNo-bindNum"));


        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b080.01", "300002", reqBody),
                netCallBack)).start();
    }

    private static String intToHex(int n) {
        StringBuilder sb = new StringBuilder(8);
        String a;
        char[] b = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        while (n != 0) {
            sb = sb.append(b[n % 16]);
            n = n / 16;
        }
        a = sb.reverse().toString();
        return a;
    }

    /**
     * 个人理财明细查询 特殊业务
     *
     * @param AcctNo    账号
     * @param PinBlock  密码
     * @param StartDate 开始时间 YYYYMMDD
     * @param ENDDate   结束日期 YYYYMMDD
     * @return String
     */
    public static void getPersonalFinancialDetailsInquiry(String AcctNo, String PinBlock,
                                                          String StartDate, String ENDDate, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(4);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("StartDate", StartDate);
        reqBody.put("ENDDate", ENDDate);
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b086.01", "300005", reqBody),
                netCallBack)).start();

    }


    /**
     * 电子现金圈存
     *
     * @param FUNC           功能号
     * @param AcctNo         卡号
     * @param ExpdDate       有效期限
     * @param CURR_COD       币别
     * @param SecondMtCon    二磁道
     * @param PinBlock       密码
     * @param Amount         交易金额
     * @param ShopType       商户类别
     * @param ATMNo          ATM编号
     * @param ATMSeqNo       ATM交易序号
     * @param TradeCheckType 交易验证类型 送001
     * @return String
     */
    public static String getElectronicCashTransfer(String FUNC, String AcctNo,
                                                   String ExpdDate, String CURR_COD,
                                                   String SecondMtCon, String PinBlock,
                                                   String Amount, String ShopType,
                                                   String ATMNo, String ATMSeqNo, String TradeCheckType) {
        Map<String, Object> reqBody = new HashMap<>(11);
        reqBody.put("FUNC", FUNC);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("ExpdDate", ExpdDate);
        reqBody.put("CURR_COD", CURR_COD);
        reqBody.put("SecondMtCon", SecondMtCon);
        reqBody.put("PinBlock", PinBlock);
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            ToastUtils.showLong(numberFormatException.getMessage());
            return null;
        }
        reqBody.put("ShopType", ShopType);
        reqBody.put("ATMNo", ATMNo);
        reqBody.put("ATMSeqNo", ATMSeqNo);
        reqBody.put("TradeCheckType", TradeCheckType);
        return getParameterMap("pcva.trade.b084.01", "", reqBody);
    }


    /**
     * 脚本结果通知
     *
     * @param AcctNo        卡号
     * @param OldTraDate    原交易日期
     * @param OldService_id 取原交易流水号
     * @param Scr_result    脚本结果 如果长度大于6，截取6之后的信息，如果不大于6，截取最后一位
     * @param SeqNo         电子现金圈存交易C端流水号
     * @return String
     */
    public static String getScriptResultNotification(String AcctNo, String OldTraDate,
                                                     String OldService_id, String Scr_result,
                                                     String SeqNo) {
        Map<String, Object> reqBody = new HashMap<>(5);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("OldTraDate", OldTraDate);
        reqBody.put("OldService_id", OldService_id);
        reqBody.put("Scr_result", Scr_result);
        reqBody.put("SeqNo", SeqNo);
        return getParameterMap("pcva.trade.b085.01", "", reqBody);
    }


    /**
     * 定转活
     *
     * @param AcctNo      账号
     * @param Amount      金额
     * @param PinBlock    账户密码
     * @param SecondTrack 二磁道
     * @param DrawCode    支取帐户编号
     * @param Draw_NO     支取理财帐户笔号
     * @param CertType    证件种类
     * @param IDNO        证件号码
     * @param CustName    客户名称
     * @return String
     */
    public static void getFixedTurns(String AcctNo, String Amount,
                                     String PinBlock, String SecondTrack,
                                     String DrawCode, String Draw_NO,
                                     String CertType, String IDNO, String CustName, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(5);
        reqBody.put("AcctNo", AcctNo);
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            ToastUtils.showLong(numberFormatException.getMessage());
        }
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("SecondTrack", SecondTrack);
        reqBody.put("DrawCode", DrawCode);
        reqBody.put("Draw_NO", Draw_NO);
        reqBody.put("CertType", CertType);
        reqBody.put("IDNO", IDNO);
        reqBody.put("CustName", CustName);
        reqBody.put("AppHeadCardNo", AcctNo);
        reqBody.put("AppHeadCard55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
        reqBody.put("AppHeadCardEcBalance", SPStaticUtils.getString("000000000000"));
        reqBody.put("AppHeadCardSeqNo", SPStaticUtils.getString("CardSeqNo"));
        reqBody.put("AppHeadCard55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));


        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b065.01", "200007", reqBody),
                netCallBack)).start();

    }


    /**
     * 产品参数查询
     *
     * @param ProductCode 产品代码
     * @param Amount      开户金额
     * @return String
     */
    public static void getFixedTurn(String ProductCode, String Amount, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(5);
        reqBody.put("ProductCode", ProductCode);
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
            KLog.e(MoneyUtil.getMoney(Amount) + "MoneyUtil");
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            ToastUtils.showLong(numberFormatException.getMessage());
        }
        new Thread(() ->
                postByOkGo(getParameterMap("pcva.trade.b092.01", "", reqBody),
                        netCallBack))
                .start();
    }

    /**
     * 活期转定期
     *
     * @param TradeType          交易类别
     * @param AcctNo             卡号
     * @param PinBlock           密码
     * @param DrwKind            支取类别
     * @param Amount             支取金额
     * @param DepositTerm        存期
     * @param DepositType        存款种类
     * @param DepositProductCode 存入帐户编号
     * @param SecondTrack        二磁道
     * @param DrawCode           支取帐户编号
     * @param ProductCode        产品编号
     * @param MNG_FLG            理财标志
     * @param TFT_EMP_NO         员工号
     * @param TFT_TD_INT_ACCT_NO 收息账号
     * @return String
     */
    public static void getCurrentTransfer(String TradeType, String AcctNo,
                                          String PinBlock, String DrwKind,
                                          String Amount, String DepositTerm,
                                          String DepositType, String DepositProductCode,
                                          String SecondTrack, String DrawCode,
                                          String ProductCode, String MNG_FLG,
                                          String TFT_EMP_NO, String TFT_TD_INT_ACCT_NO,
                                          NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(13);
        reqBody.put("TradeType", TradeType);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("PinBlock", PinBlock);
        reqBody.put("DrwKind", DrwKind);
        try {
            reqBody.put("Amount", MoneyUtil.getMoney(Amount));
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            ToastUtils.showLong(numberFormatException.getMessage());
        }
        reqBody.put("DepositTerm", DepositTerm);
        reqBody.put("DepositType", DepositType);
        reqBody.put("DepositProductCode", DepositProductCode);
        reqBody.put("SecondTrack", SecondTrack);
        reqBody.put("DrawCode", DrawCode);
        reqBody.put("ProductCode", ProductCode);
        reqBody.put("MNG_FLG", MNG_FLG);
        reqBody.put("TFT_EMP_NO", TFT_EMP_NO);
        reqBody.put("TFT_TD_INT_ACCT_NO", TFT_TD_INT_ACCT_NO);
        reqBody.put("DEP_DRW_CYCL", "");
        reqBody.put("AppHeadCardNo", AcctNo);
        reqBody.put("AppHeadCard55", SAXUnionFiled55Utils.returnFile55(SPStaticUtils.getString("Field55")));
        reqBody.put("AppHeadCardEcBalance", SPStaticUtils.getString("000000000000"));
        reqBody.put("AppHeadCardSeqNo", SPStaticUtils.getString("CardSeqNo"));
        reqBody.put("AppHeadCard55Length", intToHex(SPStaticUtils.getString("Field55").length() / 2));
        new Thread(() ->
                postByOkGo(getParameterMap("pcva.trade.b082.01", "200006", reqBody),
                        netCallBack)).start();
    }

    /**
     * 查询 交易查询
     *
     * @param bgtsdt      开始时间
     * @param enddate     结束时间
     * @param netCallBack
     */
    public static void gettransactionqQuery(String bgtsdt, String enddate, String status,
                                            NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>();
        reqBody.put("acctno", "");
        reqBody.put("merchantname", "");
        reqBody.put("status", status);
        reqBody.put("bgtsdt", bgtsdt);
        reqBody.put("enddate", enddate);
        reqBody.put("QueryRowNum", "100000");
        reqBody.put("QueryPageNo", "1");
        reqBody.put("divId", "");
        reqBody.put("devNum", SPStaticUtils.getString("DeviceNum"));
        reqBody.put("mesgserNo", "");
        reqBody.put("branchNo", SPStaticUtils.getString("TdgBrah"));
        new Thread(() ->
                postByOkGo(getParameterMap("aums.v203_transaction_query1", "", reqBody),
                        netCallBack)).start();
    }

    /**
     * 查询 汇总查询
     *
     * @param bgtsdt      开始时间
     * @param enddate     结束时间
     * @param netCallBack
     */
    public static void getStatisticsQuery(String bgtsdt, String enddate, String status,
                                          NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>();
        reqBody.put("devNum", SPStaticUtils.getString("DeviceNum"));
        reqBody.put("tradeType", status);
        reqBody.put("bgtsdt", bgtsdt);
        reqBody.put("enddate", enddate);
        reqBody.put("QueryRowNum", "100000");
        reqBody.put("QueryPageNo", "1");
        new Thread(() ->
                postByOkGo(getParameterMap("pcva.trade.b093.01", "", reqBody),
                        netCallBack)).start();
    }

    /**
     * 修改管理员密码
     *
     * @param OldTellerPwd
     * @param NewTellerPwd
     * @param netCallBack
     */
    public static void changeManangerPW(String OldTellerPwd, String NewTellerPwd, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>();
        reqBody.put("TellerNo", SPStaticUtils.getString("TranTellerNo"));
        reqBody.put("OldTellerPwd", EncryptUtils.encryptMD5ToString(OldTellerPwd).toUpperCase());
        reqBody.put("NewTellerPwd", EncryptUtils.encryptMD5ToString(NewTellerPwd).toUpperCase());
        reqBody.put("IsFirLogin", "0");
        new Thread(() ->
                postByOkGo(getParameterMap("pcva.device.d004.01", "", reqBody),
                        netCallBack)).start();
    }

    /**
     * 周周赢业务，定活自转业务签约查询
     *
     * @param AcctNo 银行卡号
     * @return String
     */
    public static void getSigningInquiry(String AcctNo, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("AcctNo", AcctNo);
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b077.01", "", reqBody), netCallBack)).start();
    }

    /**
     * 周周赢业务，定活自转业务详情查询
     *
     * @param ProductCode 产品代码
     * @return String
     */
    public static void getSigningDetailsInquiry(String ProductCode, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(1);
        reqBody.put("ProductCode", ProductCode);
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b083.01", "", reqBody), netCallBack)).start();
    }


    /**
     * 周周赢业务，定活自转业务签约
     *
     * @param AcctNo       账号
     * @param ProductCode  产品代码
     * @param TransAmt     自动转存基数
     * @param FdepAmt      起存金额
     * @param BalanceLimit 余额下限
     * @param PinBlock     密码
     * @return String
     */
    public static void getSigningBusinessContract(String menucode, String AcctNo, String ProductCode,
                                                  String TransAmt, String FdepAmt,
                                                  String BalanceLimit, String PinBlock, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(6);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("ProductCode", ProductCode);
        try {
            reqBody.put("TransAmt", TransAmt);

            reqBody.put("FdepAmt", FdepAmt);

            reqBody.put("BalanceLimit", BalanceLimit);
        } catch (NumberFormatException numberFormatException) {
            numberFormatException.printStackTrace();
            ToastUtils.showLong(numberFormatException.getMessage());
        }
        reqBody.put("PinBlock", PinBlock);
        new Thread(new Runnable() {
            @Override
            public void run() {
                postByOkGo(getParameterMap("pcva.trade.b078.01", menucode, reqBody), netCallBack);
            }
        }).start();

    }


    /**
     * 周周赢业务，定活自转业务解约
     *
     * @param AcctNo   账号
     * @param PinBlock 密码
     * @return String
     */
    public static void getSigningBusinessTermination(String menucode, String AcctNo, String PinBlock, NetCallBack netCallBack) {
        Map<String, Object> reqBody = new HashMap<>(6);
        reqBody.put("AcctNo", AcctNo);
        reqBody.put("PinBlock", PinBlock);
        new Thread(() -> postByOkGo(getParameterMap("pcva.trade.b079.01", menucode, reqBody), netCallBack)).start();
    }


    /**
     * 交易统计历史查询
     *
     * @param tradeType   交易状态
     * @param bgtsdt      开始时间
     * @param enddate     结束时间
     * @param QueryRowNum 行数
     * @param QueryPageNo 页数
     * @return
     */
    public static String getTransactionStatisticsHistoryQuery(String tradeType, String bgtsdt,
                                                              String enddate, String QueryRowNum, String QueryPageNo) {
        Map<String, Object> reqBody = new HashMap<>(6);
        reqBody.put("devNum", "设备号");
        reqBody.put("tradeType", tradeType);
        reqBody.put("bgtsdt", bgtsdt);
        reqBody.put("enddate", enddate);
        reqBody.put("QueryRowNum", QueryRowNum);
        reqBody.put("QueryPageNo", QueryPageNo);
        return getParameterMap("pcva.trade.b095.01", "", reqBody);
    }


    /**
     * 主秘钥计算
     *
     * @param key1 分量秘钥1
     * @param key2 分量秘钥2
     * @return 主秘钥
     */
    public static String getPrimarySecretKey(String key1, String key2) {
        StringBuilder secretKey = new StringBuilder();
        if (!TextUtils.isEmpty(key1) && !TextUtils.isEmpty(key2)) {
            for (int i = 0; i < 32; i++) {
                secretKey.append(Integer.toHexString(Integer.valueOf(key1.substring(i, i + 1), 16) ^
                        Integer.valueOf(key2.substring(i, i + 1), 16)).toUpperCase());
            }
            return secretKey.toString();
        }
        return null;
    }


    /**
     * 通用方法
     *
     * @param transServiceCode 交易码
     * @return String
     */
    private static String getParameter(String transServiceCode) {
        return getParameterMap(transServiceCode, "", new HashMap<>(0));
    }
}